/**
 * 简单颜色操作
 * @date   2011-3-27
 * @author tianye
 */
package cn.edu.dlut.WingGame.BaseType;

import android.graphics.Color;

public class WingColor {
	public int r;
	public int g;
	public int b;
	public int alpha = -1;

	public WingColor() {
		this.r = 0;
		this.g = 0;
		this.b = 0;
		this.alpha = -1;
	}

	public WingColor(int r, int g, int b, int alpha) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.alpha = alpha;
	}

	public WingColor(float r, float g, float b, float alpha) {
		this.r = (int) (r * 255);
		this.g = (int) (g * 255);
		this.b = (int) (b * 255);
		this.alpha = (int) (alpha * 255);
	}

	public WingColor(int r, int g, int b) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.alpha = -1;
	}

	public void setColor(int r, int g, int b, int alpha) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.alpha = alpha;
	}

	public void setColor(int r, int g, int b) {
		this.r = r;
		this.g = g;
		this.b = b;
		this.alpha = -1;
	}

	public int getA() {
		return alpha;
	}

	public int getR() {
		return r;
	}

	public int getG() {
		return g;
	}

	public int getB() {
		return b;
	}

	public float getAf() {
		return alpha / 255.0f;
	}

	public float getRf() {
		return r / 255.0f;
	}

	public float getGf() {
		return g / 255.0f;
	}

	public float getBf() {
		return b / 255.0f;
	}

	public int getRGB() {
		return Color.rgb(r, g, b);
	}

	public int getColor() {
		if (alpha == -1)
			return Color.argb(255, r, g, b);
		else
			return Color.argb(alpha, r, g, b);
	}

	public boolean hasAlpha() {
		if (alpha == -1 || alpha == 255)
			return false;
		else
			return true;
	}

}
